#include "moduleJudge.hpp"

ModuleJudge::ModuleJudge() {
    filter_lang = COMPILE_LANGUAGE | INTERPRETER_LANGUAGE;
}

ProcessStatus ModuleJudge::init(run_code_context_t<ModuleJudge>& context) {
    if (auto res = JudgeType::init(context); res.result != RUN_OK) {
        return res;
    }
    CorrectOutComponent::init(context.params.dataPath);
    spjFiles = searchFiles(context.params.spjPath, "spj", startWith);
    spjCacheFiles = spjFiles;

    for (auto& file : spjFiles) {
        file = osJoin(context.params.spjPath, file);
    }
    for (auto& file : spjCacheFiles) {
        auto langStr = findSpjFileLangType(file);
        if (langStr.empty()) {
            continue;
        }

        auto lang = langMap[langStr];
        if (!lang) {
            continue;
        }
        file = lang->detect(file, context.params.spjCachePath);
    }

    return ProcessStatus{ .result = RUN_OK };
}


